/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-18
 * Time: 19:47
 */
public class test2 {
    public int minCostClimbingStairs(int[] cost) {
        // write code here
        if(cost==null){
            return 0;
        }
        int n = cost.length;
        if(n==0 || n==1 || n==2){
            return 0;
        }
        int[] dp = new int[n];
        dp[0] = cost[0];
        dp[1] = cost[1];
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[n-1],dp[n-2]) + cost[i];
        }
        return Math.min(dp[n-1],dp[n-2]);
    }
}
